package com.zzq.my.jetpacks.jectpackapp.ui.act

import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.databinding.ActivityInterceptordialogBinding
import com.zzq.my.jetpacks.jectpackapp.intercept.InterceptChain
import com.zzq.my.jetpacks.jectpackapp.intercept.impl.*

/**
 * 描述：弹窗顺序 参考okhttp 拦截器的模式
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class InterceptorDialogActivity : BaseActivity(R.layout.activity_interceptordialog) {
    private val vb by viewBinding(ActivityInterceptordialogBinding::bind)
    private lateinit var newMemberIntercept: InterceptNewMember


    /**
     * 初始化数据
     */
    override fun initData() {


    }

    /**
     * 初始化操作
     */
    override fun initView() {

    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {
        vb.stvItemName.setOnClickListener{
            val bean = JobInterceptBean(false, false, false, false, true, true, true, true, true, true)

            createIntercept(bean)
        }
    }

    //创建拦截弹窗
    private fun createIntercept(bean: JobInterceptBean) {
        newMemberIntercept = InterceptNewMember(bean)

        val chain = InterceptChain.create(4)
            .attach(this@InterceptorDialogActivity)
            .addInterceptor(newMemberIntercept)
            .addInterceptor(InterceptFillInfo(bean))
            .addInterceptor(InterceptMemberApprove(bean))
            .addInterceptor(InterceptSkill(bean))
            .build()

        //开始执行
        chain.process()

    }
}